#set(title="在线提问")
#@WeuiLayout()
#define content()
<div class="weui-tab">
  <div class="weui-tab__bd">
		<form onsubmit="return ajaxSubmit(this)" style="padding-bottom: 30px">
			<div class="weui-cells__title">问题分类</div>
			<div class="weui-cells weui-cells_form">
			  <div class="weui-cell">
			    <div class="weui-cell__bd">	      
			    <select name="catalog_id" class="weui-select">
	      	#for(item1:catalogList)
	      		<option value="#(item1.id)" #if(item1.is_select=='F')disabled="disabled"#elseif(catalog_id??&&catalog_id==item1.id)selected="selected"#end>|-#(item1.name)</option>
	      		#for(item2:item1.children)
	      			<option value="#(item2.id)" #if(item2.is_select=='F')disabled="disabled"#elseif(catalog_id??&&catalog_id==item2.id)selected="selected"#end>|--#(item2.name)</option>
		      		#for(item3:item2.children)
		      			<option value="#(item3.id)" #if(item3.is_select=='F')disabled="disabled"#elseif(catalog_id??&&catalog_id==item3.id)selected="selected"#end>|---#(item3.name)</option>
		      		#end
	      		#end
	      	#end
	      </select>
			    </div>
			  </div>
			</div>
			<div class="weui-cells__title">问题标题</div>
			<div class="weui-cells weui-cells_form">
			  <div class="weui-cell">
			    <div class="weui-cell__bd">
			      <input class="weui-input" type="text" name="title" placeholder="请输入问题标题">
			    </div>
			  </div>
			</div>
			<div class="weui-cells__title">问题描述</div>
			<div class="weui-cells weui-cells_form">
			  <div class="weui-cell">
			    <div class="weui-cell__bd">
			      <textarea class="weui-textarea" placeholder="详细描述问题内容" name="content" rows="3"></textarea>
			      <div class="weui-textarea-counter">100字以内</div>
			    </div>
			  </div>
		  </div>
			<div class="weui-btn-area">
      	<button type="submit" class="weui-btn weui-btn_primary">立刻提交</button>
    	</div>
		</form>
  </div>
</div>
#end
#define jsFunction()
<script>
	function ajaxSubmit(obj){
		$.ajax({
			type:"POST",
			url:"saveQuestion",
			data:$(obj).serialize(),
			dataType:"json",
			async:false,
			success:function(data){
				if(data.result=="success"){
					if(data.is_pass=='T'){
						layer.alert("提问成功！",{icon:1},function(){
							location.href="show?id="+data.id;
						});
					}else {
						layer.alert("问题提交成功，请耐心等待审核！",{icon:1},function(){
							location.href="show?id="+data.id;
						});
					}
				}else {
					layer.alert(data.message,{icon:2});
				}
			}
		});
		return false;
	}
</script>
#end